package com.cloudwise.isop.kg.linstener;

import com.cloudwise.isop.kg.dao.UserDao;
import com.cloudwise.isop.kg.pojo.User;
import com.cloudwise.isop.kg.utils.SpringUtil;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 审批流程组长
 */
@Component
public class GroupManagerLinstener implements TaskListener {
    private UserDao userDao;

    @Override
    public void notify(DelegateTask delegateTask) {
        userDao = (UserDao) SpringUtil.getBean("userDao");
        List<User> users = userDao.getUsers();
        List<String> userList = new ArrayList<>();
        users.forEach(user->{
            userList.add(user.getUser_id() + "");
        });
        delegateTask.addCandidateUsers(userList);
    }
}
